{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
<input type="hidden" name='id' id='id' value="{$info.id}" />
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">标题：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" name="title" id="title" value="{$info.title}" name="name" class="form-control" placeholder="请输入标题"  >
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">视频：</label>
						<div class="col-sm-6">
							<li id="videos_upload"></li>
							<div class="videos pic_list">
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none videos_process"></span>
						</div>
					</div>




				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.update()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js?v=4" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
	layui.config({
		base: '../../static/js/plugins/layui/mods/',//相对路径
		version: '1.0'
	});

laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
laydate.render({elem: '#expiretime',type: 'datetime',trigger:'click'});
	uploader('videos_upload', 'videos', 'video', true, '{$info.videos}', '{:getUploadServerUrl()}');
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {}
}

CodeInfoDlg.collectData = function () {
	this.set('id').set('title');
};



CodeInfoDlg.update = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }

	var videos = [];
	$(".videos li").each(function () {
		if ($(this).find('i')) {
			videos.push($(this).find('i').text())
		}
	});


	 var ajax = new $ax(Feng.ctxPath + "/ZhAvideo/update", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	ajax.set('videos', JSON.stringify(videos));
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
